import React from 'react'
import './Login.css'
import { Form, Input, Button, } from 'antd-mobile'
import {getLogin} from '../../request/index'
import { useNavigate } from 'react-router-dom'
import { LeftOutline } from 'antd-mobile-icons'
const Login = () => {
const navigate=useNavigate()
  const onFinish=(values:any)=>{
    console.log(values);
   getLogin({}).then((res)=>{
    localStorage.setItem('token',res.data.data.token)
    console.log(res);
    window.location.href='/Mywz'
    
   })
}
    

    return (
        
        <div>
            <div>
                <span className='ioc' onClick={()=>(navigate(-1))}><LeftOutline /></span>
            </div>
            <Form
            onFinish={onFinish}
                layout='horizontal'
                footer={
                    <Button block type='submit' color='primary' size='large'>
                        登录
                    </Button>
                }
            >
                <Form.Item
                    name='username'
                    label='用户名'
                    rules={[{ required: true, message: '用户名不能为空' },
                        {min: 8, message: '用户名格式不对'}
                    ]}
                >
                    <Input  placeholder='请输入用户名' />
                </Form.Item>
                <Form.Item
                    name='password'
                    label='密码'
                    rules={[{ required: true, message: '密码不能为空' },
                        { min: 6, message: '密码不能少于6位' } 
                    ]}
                >
                    <Input  placeholder='请输入密码' type="password"/>
                </Form.Item>
            </Form>

        </div>
    )
}

export default Login
